-- calc.lua
-- 定义一个四则运算函数
function calculate(operation, a, b)
    if operation == "add" then
        return a + b
    elseif operation == "subtract" then
        return a - b
    elseif operation == "multiply" then
        return a * b
    elseif operation == "divide" then
        if b == 0 then
            error("Division by zero!") -- 处理除以零的错误
        end
        return a / b
    else
        error("Invalid operation!") -- 处理无效操作
    end
end
